package user

import (
	"github.com/gin-gonic/gin"
)

// RegisterRoutes 注册用户模块路由
func RegisterRoutes(r *gin.Engine, controller Controller) {
	// 用户相关路由
	userGroup := r.Group("/api/users")
	{
		userGroup.POST("", controller.CreateUser)
		userGroup.GET("/:id", controller.GetUserByID)
		userGroup.GET("/username/:username", controller.GetUserByUsername)

		userGroup.PUT("/:id", controller.UpdateUser)
		userGroup.DELETE("/:id", controller.DeleteUser)
		userGroup.GET("", controller.ListUsers)
		userGroup.POST("/login", controller.Login)
	}
}

// SetupUserModule 设置用户模块
func SetupUserModule(router *gin.Engine) Controller {
	repo := NewRepository()
	service := NewService(repo)
	controller := NewController(service)
	
	RegisterRoutes(router, controller)
	return controller
}